package com.yimi.yinhepda.adapter.RecycleAdapter;

import android.content.Context;
import android.view.View;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.entity.response.QueryUnLoadDetailBillcode;
import com.yimi.yinhepda.utils.Common;

import java.util.List;

/**
 * @author 000432
 * @date 2018/6/26 0026
 * 托盘绑定数据列表适配器
 */

public class PalletBindAdapter extends CommonRecycleAdapter<QueryUnLoadDetailBillcode> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener mCommonClickListener;

    public PalletBindAdapter(Context context, List<QueryUnLoadDetailBillcode> dataList,
                             CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.adapter_pallet_bind_item);
        this.mContext = context;
        this.mCommonClickListener = commonClickListener;
    }

    @Override
    public void bindData(CommonViewHolder holder, QueryUnLoadDetailBillcode data, int position) {
        holder.setText(R.id.tv_waybillNo, data.getWaybillNo());
        holder.setText(R.id.tv_areaCode, data.getAreaCode());
        holder.setText(R.id.tv_nextStation, data.getNextDeptName());
        holder.setText(R.id.tv_scanNum, data.getPalletBindScanCount() + "");
        holder.setCommonClickListener(mCommonClickListener);
        View view = holder.getView(R.id.ll_pallet_bind_item);
        if (data.isCheck()) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.yellow));
        } else {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }

        //二级排序：获取产品类型
        int secondSort = data.getSecondSort();
        holder.setText(R.id.tv_produce_type, Common.getSecondType(secondSort));
    }
}
